#pragma once
#ifndef CLIB_STACK_MALLOC_H
#define CLIB_STACK_MALLOC_H

#include "clib_malloc.h"
#include <stdlib.h>

#ifdef __cplusplus
extern "C" {
#endif

#define  clib_stack_mem_name        clib_stack_malloc_get_name()
#define  clib_stack_malloc          stack_malloc.clib_malloc
#define  clib_stack_free            stack_malloc.clib_free

extern clib_malloc_t stack_malloc;

/**
 * @brief glibc 内存申请函数
 * 
 * @param type 
 * @param size 
 * @param align 
 * @param socket 
 * @return void* 
 */
static inline void*
glibc_malloc(const char *type, size_t size, unsigned align, int socket)
{
    (void)type;
    (void)socket;
    size = (size + (align - 1)) & (~(align-1));

    return malloc(size);
}

/**
 * @brief 设置内存申请释放函数
 * 
 * @param mal 
 */
void
clib_stack_malloc_set(clib_malloc_t* mal);

/**
 * @brief 获取当前内存函数类型
 * 
 * @return const char* 
 */
const char*
clib_stack_malloc_get_name();

#ifdef __cplusplus
}
#endif

#endif 



